package com.orjl.networkj;

import android.content.Context;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * 版权：易金 版权所有
 * <p>
 * 作者：suntinghui
 * <p>
 * 创建日期：2019/5/20 0020 16:02
 * <p>
 * 描述：
 * <p>
 * 修订历史：
 */
public abstract class BaseObserver<T> implements Observer<BaseResponseObjectModel<T>> {


    private Context context;

    public BaseObserver(Context context) {
        this.context = context.getApplicationContext();
    }


    @Override
    public void onSubscribe(Disposable d) {

    }

    @Override
    public void onNext(BaseResponseObjectModel<T> tBaseResponseModel) {

        if (tBaseResponseModel.isSuccess() && tBaseResponseModel.getResult() != null) {
            onSuccess(tBaseResponseModel.getResult());
        }
    }

    @Override
    public void onError(Throwable e) {

    }

    @Override
    public void onComplete() {
    }


    public abstract void onSuccess(T t);

    public void onFailure(String code, String msg) {

    }


}
